package cool.taomu.software.fig.spring.example.service;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;

import org.springframework.stereotype.Service;
import org.springframework.util.StreamUtils;

import cool.taomu.software.fig.networking.Requests;

@Service
public class Collection {

	public void collection(String code) {
		Requests req = new Requests();
		req = req
				.get("http://quotes.money.163.com/service/chddata.html?code=0" + code + "&start=20200101&end=20201231");
		req.ignoreContentType(true);
		try {
			String csv = StreamUtils.copyToString(req.execute().bodyStream(), Charset.forName("GBK"));
			System.out.println(csv);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void p(String str) {
		System.err.println(str);
	}

	public static void main(String[] args) {
		Collection c = new Collection();
		c.collection("601398");
	}
}
